import React, { useRef } from 'react'
import { Button, StyleSheet, Text, TextInput, View } from 'react-native'
import CustomInput from './CustomInput'

import CustomInput2 , {CustomInputRef} from './CustomInput_2';

export default function RefDemo() {
  const inputRef = useRef<TextInput>(null);
  // 测试暴露 api
  const inputRef2 = useRef<CustomInputRef>(null);
  return (
    <View>
      {/* 
      <View style={styles.btn}>
        <Button title='聚焦' onPress={() => {
          inputRef.current?.focus();
        }} />
      </View>
      <View style={styles.btn}>
        <Button title='失焦' onPress={() => {
          inputRef.current?.blur();
        }} />
      </View>
      <CustomInput ref={inputRef} /> 
      */}
  
      <Button title='聚焦' onPress={() => {
        inputRef2.current?.customFocus();
      }} />
      <Button title='失焦' onPress={() => {
        inputRef2.current?.customBlur();
      }} />
      {/* <CustomInput ref={inputRef} /> */}

      <CustomInput2 ref={inputRef2} />


    </View>
  )
}
const styles = StyleSheet.create({
  btn: {
    margin: 20
  }
})